import { type PropType } from 'vue';
import { type VxeTablePropTypes } from 'vxe-table';

export const customProps = {
  /** 筛选表单的数据 */
  formData: {
    type: Object as PropType<Record<string, any>>,
    default: () => ({})
  },
  /** 自动加载 */
  autoLoad: {
    type: Boolean as PropType<boolean>,
    default: true
  },
  /** 是否开启分页 */
  paged: {
    type: Boolean as PropType<boolean>,
    default: false
  },
  /** 异步加载Table数据的方法 */
  load: {
    type: Function as PropType<loadPaginationRequest>,
    required: true
  },
  /** 在初始化Table之前需要执行的钩子函数 */
  beforeInitTable: {
    type: Function as PropType<() => Promise<any>>,
    default: undefined
  },
  /** 在执行了加载方法之后执行的钩子函数 */
  afterLoadedTable: {
    type: Function as PropType<() => Promise<any>>,
    default: undefined
  },
  /** 显示工具栏 */
  showTools: {
    type: Boolean as PropType<boolean>,
    default: true
  },
  /** 导出方法 */
  exportMethod: {
    type: Function as PropType<() => any>,
    default: undefined
  },
  /** 导入方法 */
  importMethod: {
    type: Function as PropType<() => any>,
    default: undefined
  },
  /**
   * 页码配置
   * 默认： [10, 20, 30, 40, 50, 100]
   */
  pageSizes: {
    type: Array as PropType<Array<number>>,
    default: () => [10, 20, 30, 40, 50, 100]
  }
};

const overrideProps = {
  border: {
    type: String as PropType<VxeTablePropTypes.Border>
  },
  keepSource: {
    type: [Boolean, String] as PropType<VxeTablePropTypes.KeepSource>,
    default: () => false
  },
  sortConfig: {
    type: Object as PropType<VxeTablePropTypes.SortConfig>,
    default: () => ({ remote: true })
  },
  columnConfig: {
    type: Object as PropType<VxeTablePropTypes.ColumnConfig>,
    default: () => ({ resizable: true, isCurrent: false })
  },
  rowConfig: {
    type: Object as PropType<VxeTablePropTypes.RowConfig>,
    default: () => ({ isCurrent: true, keyField: 'id', isHover: true })
  },
  showOverflow: {
    type: [Boolean, String, Object] as PropType<VxeTablePropTypes.ShowOverflow>,
    default: () => null
  },
  minHeight: {
    type: [Number, String] as PropType<VxeTablePropTypes.MinHeight>,
    default: () => '66px'
  },
  treeConfig: {
    type: Object as PropType<VxeTablePropTypes.TreeConfig>,
    default: () => null
  }
};

export default {
  ...customProps,
  ...overrideProps
};
